﻿#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

int main1()
{
    int num = -1;
    int i = 0;
    int count = 0;//计数
    for (i = 0; i < 32; i++)
    {
        if (num & 1)
            count++;
        num = num >> 1;
    }
    printf("二进制中1的个数为：%d\n", count);

    return 0;
}

int main()
{
    int a = 13;
    int n = 5;//第五位改变
    a = a | (1 << (n - 1));
    printf("a = %d\n", a);
    a = a ^ (1 << (n - 1));
    printf("a = %d\n", a);

    return 0;
}
